//
// Created by Luhang on 2023/3/19/019.
//

#ifndef INC_0204_DATA_H
#define INC_0204_DATA_H

#endif //INC_0204_DATA_H

#include <iostream>
#include <cassert>
using namespace std;

class Data{
    friend ostream& operator<<(ostream& out, const Data& d);
    friend istream& operator>>(istream& in, Data& d);

public:
    Data(int year = 2017, int month = 9, int day = 30);

    ~Data(){
        cout << "~Data()" << endl;
    }

    void Print(){
        cout << _year << "/" << _month << "/" << _day << endl;
    }

    //const修饰*this,this的类型变为const Data*
    //内部不改变成员变量的成员函数，最好加上const
    int GetMonthDay(int year, int month) const;

    bool operator==(const Data& d)const{
        return _year == d._year && _month == d._month && _day == d._day;
    }

    bool operator<(const Data& d)const{
        return _year < d._year || (_year == d._year && _month < d._month)
               || (_year == d._year && _month == d._month && _day < d._day);
    }

    bool operator<=(const Data& d)const{
        return *this < d || *this == d;
    }

    bool operator!=(const Data& d)const{
        return !(*this == d);
    }

    bool operator>(const Data& d) const{
        return !(*this <= d);
    }

    bool operator>=(const Data& d) const{
        return !(*this < d);
    }

    Data& operator+=(int day);
    Data operator+(int day)const;
    Data& operator-=(int day);
    Data operator-(int day)const;

    //d1-d2
    int operator-(const Data& d)const;

    //++d
    Data& operator++();

    //d++
    Data operator++(int);

    //--d
    Data& operator--();

    //d--
    Data operator--(int);

private:
    int _year;
    int _month;
    int _day;
};

inline ostream& operator<<(ostream& out, const Data& d){
    out << d._year << "/" << d._month << "/" << d._day << endl;
    return out;
}

inline istream& operator>>(istream& in, Data& d){
    in >> d._year >> d._month >> d._day;
    return in;
}